#ifndef TEMPADC_H
#define TEMPADC_H

// #include <stdint.h>
#include "typed.h"
#include "TempSysType.h"

extern uint8_t ch;

//使用之前需要实现函数接口: adc_model_init();
//初始化调用: ADInit();
//主循环调用: ADSampling();
//ADC工作时钟源,2ms定时调用: ADClock();

//函数接口
extern double (*ADC_Convert_R)(uint32_t ad); //将AD值转换成电压值
extern void (*TempADC_Delay0ms_Output)(void); //tick 0ms,输出 铂电阻状态


typedef struct __RTD
{
    int32_t value; //Integer that contains the process value
    _Pt_Status status;
}_RTD;
extern _RTD RTD[3];


//define temperature constant
#define LOW_TEMP (120)
//#define LOW_TEMP_C    (48)
#define HIGH_TEMP (650) //modify by eric 20161012  550->620->650
//#define HIGH_TEMP_C  (287)
#define AD_NEG_40F 3583 //(471)
#define AD_0F 3558 //3695 //(496)
#define AD_32F 3539 //3539 //(515)
// #define AD_212F (598)
// #define AD_212F_DW (596) //DW: Trying this so there isn't as big as a gap in temperatures between boundaries
#define AD_550F 3329 //(725)    //550->695    715-->620
#define AD_MaxF 3054 //(1000)    //550->695    715-->620

#define RTD_OPEN (1)
#define RTD_SHORT (2)
#define HIGH_ALARM (3)
#define LOW_ALARM (4)
#define IN_WORK (5)
#define PRO_SHORT (6)

extern uint8_t LowTemp_Ctrl;

void ADInit(void);
void ADC_Clock(void);
void ADSampling(void);
void TempADC_Main(void);
void LowTempAlarm(void);
void ADC_KeyUpDown(void);

#endif
